// 路由引入各个组件
import Vue from "vue";
import VueRouter from "vue-router";
//引入登录页面
import Login from "../views/login/login.vue"
// 引入主页面
import Layout from "../components/Layout.vue"
// 引入首页
import Home from "@/views/home/Home.vue"
// 引入小区
import Plot from "@/views/plot/Plot.vue"
// 引入小区
import Role from "@/views/role/Role.vue"
// 引入物业
import Real from "@/views/real/Real.vue"
// 引入其他
import Rest from "@/views/rest/Rest.vue"
import RestUpdate from "@/views/rest/RestUpdate.vue"
// 引入安保
import Security from "@/views/security/Security.vue"
// 引入区域
import Area from "@/views/plot/Area.vue"
// 引入单元
import Building from "@/views/plot/Building.vue"
// 引入楼栋
import Cell from "@/views/plot/Cell.vue"
Vue.use(VueRouter);
const routes = [
  // 登录页
  {
    path: "/login",
    name: "login",
    component: Login,
  },
  // 基础布局
  {
    path: "/",
    name: "layout",
    component: Layout,
    redirect: "/home", //重定向
    children: [
      {
        path: "/home",
        component: Home,
        meta: { title: "首页" },
      },
      {
        path: "/real",
        component: Real,
        meta: { title: "物业信息" },
      },
      {
        path: "/security",
        component: Security,
        meta: { title: "安保信息" },
      },
      {
        path: "/rest",
        component: Rest,
        meta: { title: "住户信息" },
      },
      {
        path: "/role",
        component: Role,
        meta: { title: "角色管理" },
      },
      {
        path: "/plot",
        component: Plot,
        meta: { title: "小区管理" },
      },
      {
        path: "/area",
        component: Area,
        meta: { title: "区域管理" },
      },
      {
        path: "/building",
        component: Building,
        meta: { title: "楼栋管理" },
      },
      {
        path: "/cell",
        component: Cell,
        meta: { title: "单元管理" },
      },
      {
        path: `/rest/update/:_id`,
        component: RestUpdate,
        meta: { title: "编辑住户信息" },
      },
    ],
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
